﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Linq;
using System.Collections.ObjectModel;
namespace SuperDeepZoom
{

    /// <summary>
    /// The filter helper privides support for filtering images in the MSI (MultiScaleImage)
    /// </summary>
    public class FilterHelper
    {
        MultiScaleImage msi;
        
        public FilterHelper(MultiScaleImage msi)
        {
            this.msi = msi;
        }

        public List<MultiScaleSubImage> AllImages()
        {
            return msi.SubImages.ToList<MultiScaleSubImage>();
        }

        public List<MultiScaleSubImage> FilterImages(List<int> imageIds)
        {
            List<MultiScaleSubImage> result = new List<MultiScaleSubImage>();

            foreach (var id in imageIds)
            {
                if (msi.SubImages.Count > id)
                {
                    result.Add(msi.SubImages[id]);
                }
            }

            return result;            
        }

        public List<MultiScaleSubImage> ImagesToHide(List<MultiScaleSubImage> imagesToShow)
        {
            List<MultiScaleSubImage> result = new List<MultiScaleSubImage>();

            foreach (var img in msi.SubImages)
            {
                if (!imagesToShow.Contains(img))
                {
                    result.Add(img);
                }
            }

            return result;
        }
    }
}
